package Operation;

import Book.Book;
import Book.Bookshelf;

import java.util.Scanner;

public class ReturnBook implements IOperation{

    @Override
    public void working(Bookshelf bookshelf) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入您所想要归还的图书的名字：");
        String bookName = scanner.nextLine();

        //遍历书架上的所有图书
        for (int i = 0; i < bookshelf.bookShelfNumber; i++) {
            Book book = bookshelf.books[i];
            if (bookName.equals(book.getName())) {
                book.setBorrow(false);
                return;
            }
        }
        System.out.println("对不起，书架上没有您所想要归还的图书!!!");
    }
}
